package Date_test;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.util.Date;
import java.util.Calendar;
import java.time.*;
public class test {
    public static void main(String[] args){
    String[] week = {
            "","天","一","二","三","四","五","六"
    };
        //Date类
//        Date date = new Date();
////        System.out.println(date);
////        System.out.println(date.getTime());
//        date.setTime(1737879564434L);
//        System.out.println(date);
//        System.out.println(date.getTime());
//
//        Date date2 = new Date(1000);
//        System.out.println(date2);
//        System.out.println(date2.getTime());

        //DateFormat类
//        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//        String time = dateFormat.format(date);
//        System.out.println(time);
//        Date date1 = null;
//        try{
//            date1 = dateFormat.parse("2020-01-01 16:00:00");
//        }catch (ParseException e){
//            e.printStackTrace();
//        }
//        System.out.println(date1);

        //Calendar类
//        Calendar calendar = Calendar.getInstance();
//        System.out.println(calendar.get(Calendar.HOUR));
//        System.out.println("当前时间为"+calendar.get(Calendar.YEAR) + "年" + (calendar.get(Calendar.MONTH) + 1) + "月" + calendar.get(Calendar.DAY_OF_MONTH) + "号"+ calendar.get(Calendar.HOUR_OF_DAY) + "点" + calendar.get(Calendar.MINUTE) + "分" + calendar.get(Calendar.SECOND) + "秒");
//        calendar.set(Calendar.YEAR, 2023);
//        calendar.set(Calendar.MONTH, 0);
//        calendar.set(Calendar.DAY_OF_MONTH, 1);
//        System.out.println("2023年1月1日是星期" + week[calendar.get(Calendar.DAY_OF_WEEK)]);
        //LocalDateTime类
        LocalDateTime localDate = LocalDateTime.of(2020, Month.JANUARY, 1, 10, 0);
        localDate.withYear(2025);
        DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
        System.out.println(localDate.format(dateFormat));
        System.out.println(localDate.withYear(2025));

    }
}
